import React from 'react';
import './cash.less';
import { Input, Button, DatePicker, Row, Col,Card,Table,Pagination,message} from 'antd';
import {browserHistory} from 'react-router';
import config from '../../config/config';
import $ from 'jquery';
const allRouter=config.router;
const InputGroup = Input.Group;
const { RangePicker } = DatePicker;
const token = sessionStorage.getItem('token');
class Cash extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            itemindex:0,
            patientInfo:'',
            feePreviewData:[],//已收费项目
            feePreviewData2:[],//退费项目
            feePreviewData3:[],//已收费未退费项目
            isAlreadyPayed:1,
            total:0,
            datalist:[],
            tabKey: 1,//当前显示的页面内容 1:待收费 2：已收费 3：已退费
            tabKey2: 1,//当前显示的页面内容 1:待收费 2：已收费 3：已退费
            visible: false,
            visible1: false,
            date:[],
            date2: ['',''], // 时间
            Inkey: '',// 关键字
            pagesize: 9,// 每页显示的页数
            pageindex: 1,// 当前页
            payerinfo:'',//患者信息
            totalmoney:0,//订单总金额
            lessmoney:0,//折后总金额
            missmoney:0,//应退金额
            datalist2:[],//退费列表
            ccnum:0,
            dismiss:0,//减免金额
            token:'',
            isAlreadyCharge:false,//未支付状态
        }
        this.changeDate = this.changeDate.bind(this);
    }
    componentWillMount() {}
    componentDidMount() {
        var ss=sessionStorage.getItem('token');
        this.setState({
            token:ss
        });
        this.getList(1);
    }
    //改变tab页面 切换登记记录与新增患者页面内容
    changeTab(key) {
        this.setState({ tabKey: key ,tabKey2: key ,pageindex:1})
        if(key===3){
            let url=allRouter.patientOrigin+'/refund/find';
            $.ajax({
                url:url,
                type: "get",
                headers: { Authorization: 'Bearer '+this.state.token},
                data:{
                    pagesize: this.state.pagesize,
                    pageindex:1,
                    state:3,
                    starttime:this.state.date2[0],
                    endtime:this.state.date2[1],
                    searchtxt:this.state.Inkey
                },
                async: true,
                success:(d)=> {
                    console.log(d);
                    if(d.code===200){
                        let datalist2=d.data;
                        for(var k=0;k<datalist2.length;k++){
                            datalist2[k].index=k+1;
                            datalist2[k].paystate==true?datalist2[k].paystate='退费成功':datalist2[k].paystate='退费失败';
                            let missmoney=0;
                            for(let m=0;m<datalist2[k].chargeschedule.length;m++){
                                missmoney+=parseFloat(datalist2[k].chargeschedule[m].p_dismoney);
                            }
                            datalist2[k].missmoney=missmoney;
                        }
                        this.setState({
                            datalist2:datalist2,
                            total:d.count,
                            feePreviewData2:[]
                        });
                    }else{
                        message.info('查询失败，请重新操作！');
                    }

                }
            });
        }else{
            this.getList(key);
        }
    }
    //改变tab页面 切换登记记录与新增患者页面内容
    changeTab2(key,k,num) {
        let totalmoney=0;
        let lessmoney=0;
        for(let m=0;m<this.state.datalist[k].chargeschedule.length;m++){
            totalmoney+=parseFloat(this.state.datalist[k].chargeschedule[m].p_money);
            lessmoney+=parseFloat(this.state.datalist[k].chargeschedule[m].p_dismoney);
        }
        let url=allRouter.patientOrigin+'/patient/one/'+this.state.datalist[k].payer;
        $.ajax({
            url:url,
            type: "get",
            headers: { Authorization: 'Bearer '+this.state.token},
            success:(d)=> {
                console.log(d);
                let fee=[];
                let fee2=[];
                for(let n=0;n<this.state.datalist[k].chargeschedule.length;n++){
                    if(this.state.datalist[k].chargeschedule[n].p_paystate==1||this.state.datalist[k].chargeschedule[n].p_paystate==2)
                        fee2.push(this.state.datalist[k].chargeschedule[n]);
                }
                for(let n=0;n<this.state.datalist[k].chargeschedule.length;n++){
                    if(this.state.datalist[k].paystate===1){
                        this.state.datalist[k].chargeschedule[n].p_paystate='未支付';
                        this.setState({
                            isAlreadyCharge:false,
                        })
                    }else{
                        this.setState({
                            isAlreadyCharge:true,
                        });
                        if(this.state.datalist[k].chargeschedule[n].p_paystate==1){
                            this.state.datalist[k].chargeschedule[n].p_paystate='未支付';
                        }else if(this.state.datalist[k].chargeschedule[n].p_paystate==2){
                            this.state.datalist[k].chargeschedule[n].p_paystate='已支付';
                        }else if(this.state.datalist[k].chargeschedule[n].p_paystate==3){
                            this.state.datalist[k].chargeschedule[n].p_paystate='已退费';
                        }
                    }
                    fee.push(this.state.datalist[k].chargeschedule[n]);
                }
                this.setState({
                    tabKey: key,
                    patientInfo:{
                        myId:this.state.datalist[k].orderid,
                        _id:this.state.datalist[k]._id,
                        pid:this.state.datalist[k].payer,
                        username:this.state.datalist[k].payer_name,
                        ordertype:this.state.datalist[k].ordertype
                    },
                    feePreviewData:fee,
                    feePreviewData3:fee2,
                    isAlreadyPayed:this.state.tabKey,
                    payerinfo:d.data,
                    totalmoney:totalmoney,
                    lessmoney:lessmoney,
                    itemindex:k,
                    ccnum:num,
                    dismiss:this.state.datalist[k].remissionmoney?this.state.datalist[k].remissionmoney:0
                })

            }
        });

    }
    //改变tab页面 切换登记记录与新增患者页面内容
    changeTab3(key) {
        console.log(this.state.payerinfo);
        if(this.state.feePreviewData2.length>0){
            this.setState({
                tabKey: key
            })
        }else{
            message.error('请选择退款项目',1);
        }


    }
    //退款
    dismoney(){
        let url=allRouter.patientOrigin+'/refund/save';
        let url2=allRouter.patientOrigin+'/order/reimburse';
        console.log( this.state.payerinfo);
        console.log('fgsdfhhsfg');
        console.log(this.state.patientInfo.ordertype.slice(0,3));
        if(this.state.feePreviewData2.length>0){
            $.ajax({
                url:url,
                type: "post",
                headers: { Authorization: 'Bearer '+this.state.token},
                data:{
                    orderid: this.state.patientInfo.myId,//订单号
                    patientid: this.state.payerinfo._id,
                    refundpayer: this.state.payerinfo.username,//退款人 保存姓名，不保存患者id
                    payphone: this.state.payerinfo.userphone,//手机号码
                    ordertype: this.state.datalist[this.state.itemindex].ordertype,//消费类型
                    refundmoney: this.state.missmoney,//退款金额
                    receipts: (this.state.missmoney*(1-this.state.dismiss/this.state.lessmoney)).toFixed(2),//   实际退费金额
                    paystate: true,//   支付状态 true:退款成功    false:退款失败
                    paytype: '现金支付',//退款方式  现金支付或在线支付
                    refundoperator: JSON.parse(sessionStorage.getItem("UserInfo")).id,//退款操作人
                    chargeschedule:JSON.stringify({type: this.state.feePreviewData2, default: null}),
                },
                success:(d)=> {
                    console.log(d);
                    if(d.code==200){
                        let tfarr=[];
                        for(var p=0;p<this.state.feePreviewData2.length;p++){
                            tfarr.push(this.state.feePreviewData2[p].p_name);
                        }
                        console.log(JSON.stringify(tfarr));
                        $.ajax({
                            url:url2,
                            type: "post",
                            headers: { Authorization: 'Bearer '+this.state.token},
                            data:{
                                arr:JSON.stringify(tfarr),//退费项目名称数组
                                id:this.state.patientInfo._id,
                                money:this.state.missmoney,//退费总金额
                                operator:JSON.parse(sessionStorage.getItem("UserInfo")).id,//操作人
                                ordertype:this.state.patientInfo.ordertype.slice(0,3),
                            },
                            success:(d2)=> {
                                console.log(d2);
                                if(d2.code==200){
                                    this.setState({
                                        tabKey: 2,
                                        tabKey2: 2
                                    });
                                    message.success('退款成功', 1, ()=>{this.getpagelist(this.state.pageindex);});
                                }else{
                                    message.error('退款失败');
                                }
                            },
                            error:()=>{
                                message.error('退款失败');
                            }
                        });
                    }else{
                        message.error(d.mes);
                    }
                },
                error:function () {
                    message.error('操作失败，请重试')
                }
            });
        }else{
            message.error('请选择退款项目');
        }


    }
    //搜索关键字
    changeInkey(e) {
        this.setState({
            Inkey: e.target.value
        })
    }
    //搜索
    searchRoles(e) {
        let value = e.target.value || this.state.Inkey;
        console.log(value);
        let employeeList = [];
        this.state.allList.forEach(item=>{
            if(item.name.includes(value)){
                employeeList.push(item);
            }
        });
        employeeList.sort((a,b)=>a.index-b.index);
        this.setState({employeeList});
    }
    // 日期
    changeDate(date, str) {
        console.log(date,str)
        this.setState({
            date2:str,
            date
        });
    }
    //分页
    getpagelist(k){
        let url=allRouter.patientOrigin+'/order/find';
        let url2=allRouter.patientOrigin+'/refund/find';
        if(this.state.tabKey==3){
            $.ajax({
                url:url2,
                type: "get",
                headers: { Authorization: 'Bearer '+this.state.token},
                data:{
                    pagesize: this.state.pagesize,
                    pageindex:k,
                    state:this.state.tabKey,
                    starttime:this.state.date2[0],
                    endtime:this.state.date2[1],
                    searchtxt:this.state.Inkey
                },
                async: true,
                success:(d)=> {
                    console.log(d);
                    this.setState({
                        datalist2:d.data,
                        total:d.count,
                        pageindex:k,
                        feePreviewData2:[]
                    });

                }
            });
        }else{
            $.ajax({
                url:url,
                type: "get",
                headers: { Authorization: 'Bearer '+this.state.token},
                data:{
                    pagesize: this.state.pagesize,
                    pageindex:k,
                    state:this.state.tabKey,
                    starttime:this.state.date2[0],
                    endtime:this.state.date2[1],
                    searchtxt:this.state.Inkey
                },
                async: true,
                success:(d)=> {
                    console.log(d);
                    this.setState({
                        datalist:d.data,
                        total:d.count,
                        pageindex:k,
                        feePreviewData2:[]
                    });

                }
            });
        }
    }
    toPayConfirm(){
        console.log(this.state.patientInfo);
        browserHistory.push({pathname:'payConfirm',state:JSON.stringify({name:this.state.patientInfo.username,patientId:this.state.patientInfo.pid,myId:this.state.patientInfo._id})});
    }
    toPayCancer(n){
        console.log('aaaaaa');
        this.getList(n);
        this.setState({
            tabKey:n,
            tabKey2:n,
        })
    }
    //列表
    getList(n){
        console.log(this.state)
        let url=allRouter.patientOrigin+'/order/find';
        let url2=allRouter.patientOrigin+'/refund/find';
        if(n==3){
            $.ajax({
                url:url2,
                type: "get",
                headers: { Authorization: 'Bearer '+sessionStorage.getItem('token')},
                data:{
                    pagesize: this.state.pagesize,
                    pageindex:1,
                    state:n,
                    starttime:this.state.date2[0],
                    endtime:this.state.date2[1],
                    searchtxt:this.state.Inkey
                },
                async: true,
                success:(d)=> {
                    console.log(d);
                    this.setState({
                        datalist2:d.data,
                        total:d.count,
                        feePreviewData2:[]
                    });

                }
            });
        }else{
            $.ajax({
                url:url,
                type: "get",
                headers: { Authorization: 'Bearer '+sessionStorage.getItem('token')},
                data:{
                    pagesize: this.state.pagesize,
                    pageindex:1,
                    state:n,
                    starttime:this.state.date2[0],
                    endtime:this.state.date2[1],
                    searchtxt:this.state.Inkey
                },
                async: true,
                success:(d)=> {
                    console.log(d);
                    this.setState({
                        datalist:d.data,
                        total:d.count,
                        feePreviewData2:[]
                    });
                }
            });
        }
    }
    render(){
        const columns = [
            {
                title: '订单号',
                dataIndex: 'orderid',
                width: 150,
            }, {
                title: '支付日期',
                dataIndex: 'paytime',
                width: 150,
            }, {
                title: '退款日期',
                dataIndex: 'refundtime',
                width: 150,
            },{
                title: '支付姓名',
                dataIndex: 'refundpayer',
                width: 100,
            }, {
                title: '手机号',
                dataIndex: 'payphone',
                width: 100,
            }, {
                title: '消费类型',
                dataIndex: 'ordertype',
                width: 100,
            }, {
                title: '支付方式',
                dataIndex: 'paytype',
                width: 80,
            }, {
                title: '支付金额',
                dataIndex: 'receipts',
                width: 80,
            }, {
                title: '退费金额',
                width: 80,
                render:(text,record)=>{return <span>{record.receipts}</span>}
            }, {
                title: '支付状态',
                dataIndex: 'paystate',
                width: 80,
            }, {
                title: '操作人',
                dataIndex: 'refundoperator_name',
                width: 50
            }
        ];
        //费用预览表格
        const FeePreview = [
            {
                title: '收费名称',
                dataIndex: 'p_name',
                width: 200,
            },{
                title: '数量',
                dataIndex: 'p_Number',
                width: 100,
            },{
                title: '单价',
                dataIndex: 'p_price',
                width: 200,
            },{
                title: '规格',
                dataIndex: 'p_speci',
                width: 100,
            },{
                title: '金额',
                width: 200,
                dataIndex: 'p_money',
            },{
                title: '折扣',
                dataIndex: 'p_discount',
                width: 150,
            },{
                title: '折后金额',
                width: 200,
                dataIndex: 'p_dismoney',
            },{
                title: '接诊医生',
                width: 200,
                dataIndex: 'p_doctor',
            },{
                title: '支付状态',
                width: 200,
                dataIndex: 'p_paystate',
            }
        ];
        //费用预览表格
        const FeePreview2 = [
            {
                title: '退费名称',
                dataIndex: 'p_name',
                width: 200,
            },{
                title: '数量',
                dataIndex: 'p_Number',
                width: 100,
            },{
                title: '单价',
                dataIndex: 'p_price',
                width: 200,
            },{
                title: '规格',
                dataIndex: 'p_speci',
                width: 100,
            },{
                title: '金额',
                width: 200,
                dataIndex: 'p_money',
            },{
                title: '折扣',
                dataIndex: 'p_discount',
                width: 150,
            },{
                title: '折后金额',
                width: 200,
                dataIndex: 'p_dismoney',
            },{
                title: '接诊医生',
                width: 200,
                dataIndex: 'p_doctor',
            }
        ];
        const rowSelection = {
            onChange: (selectedRowKeys, selectedRows) => {
                console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows,this.state.feePreviewData);
                let missmoney=0;
                for(let m=0;m<selectedRows.length;m++){
                    missmoney+=parseFloat(selectedRows[m].p_dismoney);
                }
                console.log((this.state.lessmoney-this.state.dismiss).toFixed(2));
                this.setState({
                    feePreviewData2:selectedRows,
                    missmoney:missmoney
                });
            },
            getCheckboxProps: record => ({
                disabled: record.name === 'Disabled User', // Column configuration not to be checked
            }),
        };
        return (
            <div className='container triage'>
                <div className='btnBox my-clear-fix'>
                    <Button type={this.state.tabKey2 === 1 ? 'primary':''} onClick={() => this.changeTab(1)}>待收费</Button>
                    <Button type={this.state.tabKey2 === 2 ? 'primary':''} onClick={() => this.changeTab(2)}>已收费</Button>
                    <Button type={this.state.tabKey2 ===3 ? 'primary':''} onClick={() => this.changeTab(3)}>已退费</Button>
                    {
                        this.state.tabKey==4||this.state.tabKey==5?''
                            :<div className='role-manage-box-search my-clear-fix employee-manage-box-search'>
                                <div className='addetd-z employee-manage-search'>
                                    <InputGroup >
                                        <RangePicker style={{width:'600px'}}
                                                     placeholder={['请选择日期', '请选择日期']}
                                                     onChange={this.changeDate}
                                                     format='YYYY-MM-DD'
                                                     value={this.state.date}
                                        />
                                        <Input
                                            placeholder="请输入姓名或手机号"
                                            value={this.state.Inkey}
                                            onChange={(e) => this.changeInkey(e)}
                                            onPressEnter={(e)=>this.searchRoles(e)}
                                        />
                                    </InputGroup>
                                </div>
                                <div className="role-manage-right">
                                    <Button type="primary" className='member-button' icon="search" onClick={this.getList.bind(this,this.state.tabKey)}>搜索</Button>
                                </div>
                            </div>
                    }
                </div>
                {
                    this.state.tabKey == 1 ?
                        <div className='addpatient'>
                            <div style={{ background: '#ECECEC', padding: '30px' }}>
                                <Row gutter={16}>
                                    {this.state.datalist.length>0?
                                        this.state.datalist.map((item,index)=>{
                                            return <Col span={8} key={item._id}>
                                                <Card bordered={false}>
                                                    <img src={require('../../../images/patientDefault.png')} className="default-img"/>
                                                    <div className="fsecd">
                                                        <h6>{item.payer_name}<em></em></h6>
                                                        <p>就诊时间：{item.consumptiontime}</p>
                                                        <p>就诊科室：{item.department_name}</p>
                                                        <p>就诊医生：{item.doctor_name}</p>
                                                    </div>
                                                </Card>
                                                <Button  style={{width:'100%',height:'50px',fontSize:'24px',background:'#ddd'}} onClick={() => this.changeTab2(4,index,1)}>收费￥{item.consumptionmoney.toFixed(2)}</Button>
                                            </Col>
                                        }):''
                                    }
                                </Row>
                            </div>
                        </div>
                        :
                        this.state.tabKey === 2?
                        <div className='addpatient'>
                            <div style={{ background: '#ECECEC', padding: '30px' }}>
                                <Row gutter={16}>
                                    {this.state.datalist.length>0?
                                        this.state.datalist.map((item,index)=>{
                                            return <Col span={8} key={item._id}>
                                                <Card bordered={false}>
                                                    <img src={require('../../../images/patientDefault.png')} className="default-img"/>
                                                    <div className="fsecd">
                                                        <h6>{item.payer_name}<em></em></h6>
                                                        <p>就诊时间：{item.consumptiontime}</p>
                                                        <p>就诊科室：{item.department_name}</p>
                                                        <p>就诊医生：{item.doctor_name}</p>
                                                    </div>

                                                </Card>
                                                <div className="hdsf" >
                                                    <Button type="primary" style={{height:'50px',fontSize:'24px'}} onClick={() => this.changeTab2(4,index,1)}>￥{item.consumptionmoney.toFixed(2)}</Button>
                                                    <Button type="primary" style={{height:'50px',fontSize:'24px'}} onClick={() => this.changeTab2(4,index,2)}>退款</Button>
                                                </div>
                                            </Col>
                                        }):''
                                    }
                                </Row>
                            </div>
                        </div>
                            :this.state.tabKey === 3?
                        <div>
                            <Table
                            rowKey="index"
                            columns={columns}
                            dataSource={this.state.datalist2}
                            pagination={false}
                            bordered
                            />
                        </div>: this.state.tabKey === 4?<div>
                                        <div className='container triage'>
                                            <div className='box'>
                                                <div className='patientinfo'>
                                                    <img src={require('../../../images/patientDefault.png')}/>
                                                    <h6>{this.state.payerinfo.username}</h6>
                                                    <p>{this.state.payerinfo.userphone}</p>
                                                    <div className='patientinfoa'>
                                                        <p>性别：{this.state.payerinfo.usersex}</p>
                                                        <p>年龄：{(new Date().getFullYear() - (this.state.payerinfo.userbirthday ? this.state.payerinfo.userbirthday.slice(0, 4) : 1)) + '岁'}</p>
                                                        <p>婚配：{this.state.payerinfo.usermarriage}</p>
                                                        <p>身高：{this.state.payerinfo.signmes ? this.state.payerinfo.signmes[0].height === 0 ? '' : this.state.payerinfo.signmes[0].height + 'cm' : ''}</p>
                                                        <p>脉搏：{this.state.payerinfo.medica?this.state.payerinfo.medica.length!==0?this.state.payerinfo.medica[0].signmes?this.state.payerinfo.medica[0].signmes.pulse+'次/每分钟':'':'':''}</p>
                                                        <p>呼吸：{this.state.payerinfo.medica?this.state.payerinfo.medica.length!==0?this.state.payerinfo.medica[0].signmes?this.state.payerinfo.medica[0].signmes.breathe+'次/每分钟':'':'':''}</p>
                                                        <p>血压：{this.state.payerinfo.medica?this.state.payerinfo.medica.length!==0?this.state.payerinfo.medica[0].signmes?this.state.payerinfo.medica[0].signmes.bloodpressure+'mmHg':'':'':''}</p>
                                                        <p>过敏史：{this.state.payerinfo.medica?this.state.payerinfo.medica.length!==0?this.state.payerinfo.medica[0].irritability:'':''}</p>

                                                    </div>
                                                </div>
                                                <div className='patientinfo1'>
                                                    <div className='addpatient'>
                                                        <p style={{color:'#40a9ff'}}>订单号：{this.state.patientInfo.myId}</p>
                                                        <div className='bxa'>
                                                            <div>
                                                                <Row>
                                                                    <Col span={24} >
                                                                        {
                                                                            this.state.ccnum==2?
                                                                                <Table rowSelection={this.state.isAlreadyPayed==1?'':rowSelection}
                                                                                                       rowKey="index"
                                                                                                       columns={this.state.isAlreadyPayed==1?FeePreview:FeePreview2}
                                                                                                       dataSource={this.state.feePreviewData3}
                                                                                                       pagination={false}
                                                                                                       bordered
                                                                                />:<Table
                                                                                          rowKey="index"
                                                                                          columns={FeePreview}
                                                                                          dataSource={this.state.feePreviewData}
                                                                                          pagination={false}
                                                                                          bordered
                                                                                />
                                                                        }
                                                                    </Col>
                                                                </Row>

                                                                    {
                                                                        this.state.ccnum==2?'':<Row>
                                                                            <Row style={{marginTop:'20px'}}>
                                                                                <Col span={2} offset={18}>金额合计:</Col>
                                                                                <Col span={2} style={{color:'red'}}>￥{this.state.totalmoney.toFixed(2)}</Col>
                                                                            </Row>
                                                                            <Row>
                                                                            <Col span={2} offset={18}>减免金额:</Col>
                                                                        <Col span={2} style={{color:'red'}}>￥{this.state.dismiss.toFixed(2)}</Col>
                                                                        </Row>
                                                                        <Row>
                                                                        <Col span={2} offset={18}>应收金额:</Col>
                                                                        <Col span={2} style={{color:'red'}}>￥{this.state.lessmoney.toFixed(2)}</Col>
                                                                        </Row>
                                                                        <Row>
                                                                        <Col span={2} offset={18}>实收金额:</Col>
                                                                        <Col span={2} style={{color:'red'}}>￥{this.state.isAlreadyCharge?(this.state.lessmoney-this.state.dismiss).toFixed(2):'0.00'}</Col>
                                                                        </Row></Row>
                                                                    }

                                                                <Row style={{margin:'30px 0 10px 0'}}>
                                                                    {this.state.isAlreadyPayed==1?<div>
                                                                            <Col span={2} offset={18}>
                                                                                <Button type="primary" onClick={this.toPayConfirm.bind(this)}>去结账</Button>
                                                                            </Col>
                                                                            <Col span={2} offset={1}>
                                                                                <Button onClick={this.toPayCancer.bind(this,1)}>取消</Button>
                                                                            </Col>
                                                                        </div>: <div>
                                                                            <Col span={2} offset={18}>
                                                                                {this.state.ccnum==2?<Button type="primary" onClick={() => this.changeTab3(5)}>确定</Button>:''}
                                                                            </Col>
                                                                            <Col span={2} offset={1}>
                                                                                {this.state.ccnum==2?<Button onClick={this.toPayCancer.bind(this,2)}>取消</Button>:''}
                                                                            </Col>
                                                                        </div>}
                                                                </Row>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>:this.state.tabKey==5?<div>
                                            <div className='container triage'>
                                                <div className='box'>
                                                    <div className='patientinfo'>
                                                        <img src={require('../../../images/patientDefault.png')} className="default-img"/>
                                                        <h6>{this.state.payerinfo.username}</h6>
                                                        <p>{this.state.payerinfo.userphone}</p>
                                                        <div className='patientinfoa'>
                                                            <p>性别：{this.state.payerinfo.usersex}</p>
                                                            <p>年龄：{(new Date().getFullYear() - (this.state.payerinfo.userbirthday ? this.state.payerinfo.userbirthday.slice(0, 4) : 1)) + '岁'}</p>
                                                            <p>婚配：{this.state.payerinfo.usermarriage}</p>
                                                            <p>身高：{this.state.payerinfo.signmes ? this.state.payerinfo.signmes[0].height === 0 ? '' : this.state.payerinfo.signmes[0].height + 'cm' : ''}</p>
                                                            <p>脉搏：{this.state.payerinfo.medica?this.state.payerinfo.medica.length!==0?this.state.payerinfo.medica[0].signmes?this.state.payerinfo.medica[0].signmes.pulse+'次/每分钟':'':'':''}</p>
                                                            <p>呼吸：{this.state.payerinfo.medica?this.state.payerinfo.medica.length!==0?this.state.payerinfo.medica[0].signmes?this.state.payerinfo.medica[0].signmes.breathe+'次/每分钟':'':'':''}</p>
                                                            <p>血压：{this.state.payerinfo.medica?this.state.payerinfo.medica.length!==0?this.state.payerinfo.medica[0].signmes?this.state.payerinfo.medica[0].signmes.bloodpressure+'mmHg':'':'':''}</p>
                                                            <p>过敏史：{this.state.payerinfo.medica?this.state.payerinfo.medica.length!==0?this.state.payerinfo.medica[0].irritability:'':''}</p>

                                                        </div>
                                                    </div>
                                                    <div className='patientinfo1'>
                                                        <div className='addpatient'>
                                                            <div className='bxa'>
                                                                <div>
                                                                    <Row>
                                                                        <Col span={24} >
                                                                            <Table
                                                                                   rowKey="index"
                                                                                   columns={FeePreview2}
                                                                                   dataSource={this.state.feePreviewData2}
                                                                                   pagination={false}
                                                                                   bordered
                                                                            />
                                                                        </Col>
                                                                    </Row>
                                                                    <Row style={{marginTop:'20px'}}>
                                                                        <Col span={2} offset={1}>应退金额:</Col>
                                                                    </Row>
                                                                    <Row>
                                                                        <Col span={20} offset={1} style={{color:'red',fontSize:'30px'}}>￥{(this.state.missmoney*(1-this.state.dismiss/this.state.lessmoney)).toFixed(2)}
                                                                            <span style={{color:'#999',fontSize:'12px',marginLeft:'50px'}}>现金 <input type="radio" checked="checked" name="radio1"/> 微信 <input type="radio" disabled="disabled" name="radio1"/> 支付宝 <input type="radio" disabled="disabled" name="radio1"/></span>
                                                                        </Col>
                                                                    </Row>
                                                                    <Row style={{marginTop:'20px'}}>
                                                                        <Col span={2} offset={1}>提示:</Col>
                                                                    </Row>
                                                                    <Row>
                                                                        <Col span={20} offset={1}>如原收费单据含有优惠，则退费时只可全额退药退款。</Col>
                                                                    </Row>
                                                                    <Row style={{margin:'30px 0 10px 0'}}>
                                                                         <div>
                                                                             <Col span={2} offset={20}>
                                                                                 <Button type="primary" onClick={() => this.dismoney()}>确定退费</Button>
                                                                             </Col>
                                                                         </div>
                                                                    </Row>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>:''
                }
                {this.state.tabKey == 4||this.state.tabKey == 5?'':
                    <div className="pagination">
                        <Pagination current={this.state.pageindex} total={ this.state.total} defaultPageSize={this.state.pagesize} onChange={this.getpagelist.bind(this)}/>
                    </div>}
                {/*分页*/}
            </div>
        );
    }
}
export default Cash;